package com.lixixi.tingshu.user.listenr;

import com.alibaba.fastjson.JSONObject;
import com.lixixi.tingshu.common.constant.KafkaConstant;
import com.lixixi.tingshu.user.service.UserRecordService;
import com.lixixi.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class UserRecordListener {
	@Autowired
	UserRecordService userRecordService;

	@KafkaListener(id = "userAccountRecordByListen", topics = KafkaConstant.QUEUE_USER_PAY_RECORD)
	void userAccountRecordByListen(String userPaidRecordVoStr){
		UserPaidRecordVo userPaidRecordVo = JSONObject.parseObject(userPaidRecordVoStr, UserPaidRecordVo.class);
		userRecordService.recordItem(userPaidRecordVo);
	}
}
